package cn.com.nthotline.activity;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import cn.com.nthotline.R;

public class ArbitraryFragmentActivity extends BaseFragmentActivity {
	public static final String EXTRAS_BUNDLE = "com.instagram.android.activity.ArbitraryFragmentActivity.EXTRAS_BUNDLE";
	public static final String EXTRAS_FRAGMENT_CLASS_NAME = "com.instagram.android.activity.ArbitraryFragmentActivity.EXTRAS_FRAGMENT_CLASS_NAME";
	public static final int layout_container_main = R.id.layout_container_main;

	@Override
	protected void initializeStartingFragment() {
		if (getSupportFragmentManager().findFragmentById(layout_container_main) == null) {
			String className = getIntent().getExtras().getString(
					EXTRAS_FRAGMENT_CLASS_NAME);
			Fragment fragment;
			try {
				fragment = (Fragment) Class.forName(className).newInstance();
			} catch (Exception e) {
				throw new RuntimeException((new StringBuilder())
						.append("No fragment by the name of ")
						.append(className).append(" found").toString());
			}
			FragmentTransaction transcation = getSupportFragmentManager()
					.beginTransaction();
			fragment.setArguments(getIntent().getBundleExtra(EXTRAS_BUNDLE));
			transcation.setCustomAnimations(R.anim.push_left_in, R.anim.push_left_out,R.anim.push_right_in,R.anim.push_right_out);
			transcation.replace(layout_container_main, fragment);
			transcation.commit();
			
		}
	}

}
